03. Splitting Up the Project
Section 2: Split the Image Service into its Own Project
Now that you have identified all the dependencies and can run the project, it’s time to split things up! Remember another team wants to use the Image Service in their project. To accomplish this, you must separate the Image Service from the program and package it as a separate module to be included both in your own project and in other projects
Splitting Things Up
- Use either maven or your IDE to create a new maven project that will be the parent project for the two modules you will be creating.
- Inside of the parent project, create one module for your Security service and one module for your Image service. (Note: Use one parent pom at the top level and one child pom for each module.)
- Move all components into their proper modules.
- Update dependencies in the poms so that shared dependencies are in the parent pom, but unshared dependencies are in the child poms.
- Use the pluginManagement tag in the parent pom to set the latest versions for the core plugins used by the maven lifecycle, such as the maven-compiler-plugin.
- Create a module descriptor for each package. You will have to provide the correct
export
andrequires
statements in each of these descriptors. - Address transitive dependencies. Now that your project uses modules, you may need to open your packages to dependencies or explicitly include transitive dependencies that are required by your dependencies that do not declare them all in a
modules-info.java
. (Note: In particular, some amazon SDK dependencies do not provide modular jars but may require your project to reference the libraries they use. You might need to addrequires
* statement to your modules-info.java to reference those dependencies. See this discussion thread on modularization of aws 2.)* - Make sure the project still runs!